from typing import Type

from services.impl import douyin_service, kuaishou_service, xigua_service, pipixia_service, bilibili_service, bangumi_service
from services.service_interface import ServiceInterface
from model import VideoType

ServiceMapper = {
    VideoType.DOUYIN: douyin_service.DouyinService,
    VideoType.KUAISHOU: kuaishou_service.KuaishouService,
    VideoType.XIGUA: xigua_service.XiguaService,
    VideoType.PIPIXIA: pipixia_service.PipixiaService,
    VideoType.BILIBILI: bilibili_service.BiliBiliService,
    VideoType.BANGUMI: bangumi_service.BangumiService,
}


def get_service(xtype: VideoType) -> Type[ServiceInterface]:
    service = ServiceMapper.get(xtype)
    if service is None:
        raise ModuleNotFoundError('Not match route, type ' + xtype.label)
    return service
